﻿namespace Harness.Verificators
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using mshtml;

    internal class PathVerificator : IVerificator
    {
        #region Constants

        private const int PathArgIndex = 0;

        #endregion

        #region Public Methods

        public void SyntaxCheck(IHarness harness, IEnumerable<object> args)
        {
            if (null == args.ElementAtOrDefault(PathArgIndex))
            {
                throw new ArgumentNullException((PathArgIndex + 1).ToString() + ":Path");
            }
        }

        public bool Verify(IHarness harness, IEnumerable<object> args)
        {
            string path = (args.ElementAtOrDefault(PathArgIndex) ?? string.Empty).ToString();

            Uri url = new Uri(IE.ActiveBrowser.LocationURL);

            return path == url.AbsolutePath;
        }

        #endregion
    }
}
